import {decode as atob, encode as btoa} from 'base-64';

export default function base64ToFile(base64, fileName, mime) {
  let arr = base64.split(',');
  let bstr = atob(arr[1]);
  let n = bstr.length;
  let u8arr = new Uint8Array(n);

  while (n--) {
    u8arr[n] = bstr.charCodeAt(n);
  }
  return new File([u8arr], fileName, {type: mime});
}
